package com.dzl.api;

import com.dzl.api.pojo.dto.ExtractCardDto;
import com.dzl.api.service.ExtractCardService;
import com.dzl.operation.service.OperationLogService;
import com.dzl.util.JsonResult;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author ChenLong
 * @date 2021-11-10 10:25:19
 */
@Slf4j
@RequestMapping("extractCard")
@RestController
public class ExtractCardController {

    @Autowired
    private OperationLogService operationLogService;
    @Autowired
    ExtractCardService extractCardService;

    /**
     * 亚捷提卡回调
     * @author ChenLong
     * @date 2021-11-11 19:03:24
     * @param dto 实体
     * @return java.lang.String
     **/
    @PostMapping("notify")
    public String notify(ExtractCardDto dto){
        log.info("extractCard notify dto: " + dto);
        operationLogService.saveOrderReturnSuccess(dto.getExtOrderId(), "extractCard notify data: " + dto);
        extractCardService.updateExtractCard(dto);
        return "OK";
    }

    /**
     * 亚捷提卡测试
     * @author ChenLong
     * @date 2021-11-10 10:27:56
     * @param
     * @return java.lang.String
     **/
    @PostMapping("makeOrderTest")
    public JsonResult makeOrderTest(String productId,Integer orderId,String phone,Integer quantity){
        String result = extractCardService.extractCard(productId,orderId,phone,quantity);
        return JsonResult.success(result);
    }
}
